package parts.main; /**
 * Copyright 2011 Jonathan Haas
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import drawing.View;
import simulation.InputPin;
import simulation.OutputPin;
import simulation.Pin;

import java.awt.*;
import java.awt.geom.Path2D;

public class InverterView implements View {
    private static Path2D.Double _shape;

    private final InputPin _inputPin;
    private final OutputPin _outputPin;

    static{
        _shape = new Path2D.Double();
        _shape.moveTo(0,0);
        _shape.lineTo(0,2);
        _shape.lineTo(1,1);
        _shape.closePath();
    }

    public InverterView(final InputPin inputPin, final OutputPin outputPin) {
        _inputPin = inputPin;
        _outputPin = outputPin;
    }

    public void draw(final Graphics2D g2d, final int zoomFactor) {
        g2d.draw(_shape);
        Pin.draw(g2d, _inputPin, 1f / zoomFactor);
        Pin.draw(g2d, _outputPin, 1f / zoomFactor);
    }
}
